package stz.flash.main;

import stz.flash.Info;
import net.rim.device.api.system.Characters;
import net.rim.device.api.system.ControlledAccessException;
import net.rim.device.api.system.EventInjector.KeyEvent;
import blackberry.util.DjPermissions;


public class FlashKeyEvent{

	public static final int DELAY_ESC_VR_CLOSE = 30;
	
	private static KeyEvent spaceKey = new KeyEvent(KeyEvent.KEY_DOWN, Characters.SPACE, 0);
	private static KeyEvent escKey = new KeyEvent(KeyEvent.KEY_DOWN, Characters.ESCAPE, 0);
	
	public static void postSpaceKey(){
		try {
			spaceKey.post();
		} catch (ControlledAccessException e2) {
			invokePermissionsRequest();
		}
	}
	
	public static void postEscKey(){
		try {
			escKey.post();
		} catch (ControlledAccessException e2) {
			invokePermissionsRequest();
		}
	}
	
	private static void invokePermissionsRequest(){
		DjPermissions.invokePermissionsRequest(Info.REQUEST_PERMISSIONS);
	}
}